package com.leadbank.baselbf.user;

import android.content.Context;

import com.leadbank.baselbf.base.BaseLBFApplication;
import com.leadbank.baselbf.leadutils.LbwADIUtils;
import com.leadbank.baselbf.manager.PreferencesKey;
import com.leadbank.baselbf.manager.SPLBFManager;
import com.leadbank.baselbf.outils.StringUtil;

/**
 * @ClassName: AppUserInfo
 * @Description:
 * @Author: zhouzhiguo
 * @Date: 2024/5/27 18:41
 * @Version: 5.0.6
 * 上海利得金融科技集团版权所有.
 */

public class AppUserInfo {
    private static Context context;
    private static Context getContext(){
        if (context == null){

            context = BaseLBFApplication.getBaseApplication().getApplicationContext();
        }
        return context;
    }

    /**
     * 判断用户是否已登录
     *
     * @return ""
     */
    public static String getToken() {
        return StringUtil.nvl(SPLBFManager.getString(getContext(),PreferencesKey.TOKEN));
    }

    /**
     * 判断用户是否已登录
     *
     * @return ""
     */
    public static String get276Token() {
        String token = SPLBFManager.getString(getContext(),PreferencesKey.TOKEN);
        if (LbwADIUtils.isNvl(token)){
            token = getDeviceID();
        }
        return StringUtil.nvl(token);
    }
    public static String getDeviceID() {
        String deviceId = (SPLBFManager.getString(getContext(),PreferencesKey.DeviceId));
        if (LbwADIUtils.isNvl(deviceId)){
            deviceId = "1111165495211111111";
        }
        return deviceId;
    }

    /**
     * 仅供启动页使用
     * @return
     */
    public static String getLocalDeviceID() {
        String deviceId = (SPLBFManager.getString(getContext(),PreferencesKey.DeviceId));
        return deviceId;
    }


    /**
     * 获取salt
     * @return
     */
    public static String getLeadSalt() {
        String deviceId = (SPLBFManager.getString(getContext(),PreferencesKey.LEAD_SALT));
        return deviceId;
    }
    /**
     * 设置salt
     * @return
     */
    public static boolean setLeadSalt(String salt) {
        return SPLBFManager.setString(getContext(),PreferencesKey.LEAD_SALT, salt);
    }
    /**
     * 获取用户的 MEMBER_ID
     *
     * @return ""
     */
    public static String getMemberID() {
        return StringUtil.nvl(SPLBFManager.getString(getContext(),PreferencesKey.MEMBER_ID));
    }

    /**
     * 第一次安装启动ID
     *
     * @return ""
     */
    public static String getFirstInstallID() {
        return StringUtil.nvl(SPLBFManager.getString(getContext(),PreferencesKey.FIRSTINSTALLID));
    }

    /**
     * 启动ID
     *
     * @return ""
     */
    public static String getSessionID() {
        return StringUtil.nvl(SPLBFManager.getString(getContext(),PreferencesKey.SESSIONID));
    }
    /**
     * 启动ID
     *
     * @return ""
     */
    public static boolean setSessionID(String id) {
        return SPLBFManager.setString(getContext(),PreferencesKey.SESSIONID, id);
    }
}
